package mobilesearch.thread;

import android.content.ContentResolver;
import mobilesearch.data.EmailData;
import mobilesearch.data.CallLogData;
import mobilesearch.ui.BroadcastCommand;

import java.util.ArrayList;
import android.database.Cursor;
import android.provider.MediaStore;
import android.util.Log;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;

public class EmailSearchThread extends Thread {
	private static final String TAG = "CallLogSearchThread";
	private ContentResolver resolver;
	private Context context;
	
	public EmailSearchThread(Context context, ContentResolver resolver) {
		super();
		this.context = context;
		this.resolver = resolver;
	}

	@Override
	public void run() {
		super.run();
		
		ArrayList<EmailData> emailList = new ArrayList<EmailData>();
		try{
			Cursor cursor = this.resolver.query(Uri.parse("content://com.android.email.provider/message"),null,null,null,null);

		}catch(Exception exception){
			Log.i(TAG, exception.toString());
		}
		
		//broadcast the call log data
		if(!emailList.isEmpty()){
			Intent emailIntent = new Intent(BroadcastCommand.SEARCH_EMAIL);
			emailIntent.putParcelableArrayListExtra(BroadcastCommand.SEARCH_EMAIL, emailList);
			this.context.sendBroadcast(emailIntent);	
		}
	}
	
	
}
